//copyright by sunnyswim@gmail.com
function setfoce(a,b){//输入框提示 setfoce('#asrknow','.txtstips')
	var textAraid=a;
	var layerb=b;
	$(document).ready(function(){
	$(textAraid).hover(function(){
							   $(layerb).hide();
							   $(this).focus();
							   },
							  function() {
							   if ($(textAraid)[0].value=='')
							   {$(layerb).show();}
							   $(textAraid).focus(); 
								   }
							   )
			 })
	}

//两列对齐 a为左，b为右
  function twoAlignment(a,b){
	  var layerA=a;
	  var layerB=b;
	  $(window).load(function(){
				var leftHeight=$(layerA).height();
				var rightHeight=$(layerB).height();
				var maxHeight=Math.max(leftHeight,rightHeight);//求最大值
				//alert(leftHeight+"L"+rightHeight+"R");
				$(layerA).height(maxHeight);
				$(layerB).height(maxHeight);
							 })
	  
	  }

// 初始化背景色
function getbgcolor(a){
	var layerName=a;//a为要调整背景色的图层
	function GetRandomNum(Min,Max){//随机数范围
        var Range = Max - Min;
        var Rand = Math.random();
        return(Min + Math.round(Rand * Range));
		}
		var tempArray = new Array();//色彩数组
		tempArray [1] ="#B7EFFB";
		tempArray [2] ="#D7FFD7";
		tempArray [3] ="#FFDDDD";
		tempArray [4] ="#FFFFD0";
		tempArray [5] ="#FFBFBF";
		tempArray [6] ="#FFFFCC";
		tempArray [7] ="#fff";
		$(layerName).css("background",tempArray[GetRandomNum(1,7)]);
	}
//无限下拉菜单效果	
	function menuList(){
	$('#menuNav li').hover(function(){
		
		$(this).children('ul').fadeIn('slow');	
		
	},function(){
		$(this).children('ul').fadeOut('slow');
	});
	
}
//禁止copy
function forbidcopy(){
		function click1() {
		if (event.button==2) {alert('操作错误:禁止按鼠标右键！') }}
		function CtrlKeyDown(){
		if (event.ctrlKey) {alert('操作错误:禁止按CTRL键！') }}
		document.onkeydown=CtrlKeyDown;
		document.onmousedown=click1;
}
//tab 标签切换效果
function tabsChange(a,b,c,d){//a为tab的id或class名, b为需要切换的内容的class名,c为选中时的tab上li的样式名,d为b的高度
$(document).ready(function(){
	var layera=a;
	var layerb=b;
	var selectd=c;
	var layerbheight=d;
	$(layerb+':first').show();
	$(layerb).height(layerbheight);
	$(layera+" li").hover(
						function(){
							$(layera+" li").removeClass(selectd);
							$(layerb).hide();
							$(this).addClass(selectd);
							var aurl=$(layerb+'_'+ this.id);//当前选中对应切换的内容的id:以layera_ + 当前li上面的id
							aurl.show();
							},
						function(){}
								)
						   })
	}

//鼠标经过时层变色
function hoverDiv(a,b,c){//a为传递的div b为下一级元素如ul下面的li,c为经过时添加的样式名。 hoverDiv(".newsList"," li","hover")
	var layer=a;
	var hoverElements=b;
	var cssName=c;
	$(layer+hoverElements).hover(
								function(){
	$(this).addClass(cssName);
									},
								function(){
	$(this).removeClass(cssName);							
									}
								)						 
  }
  
  //轮播flash切换图
  function creatSwfplay(a,b,c,d,e){
	  //示例：creatSwfplay(284,217,"images/foce.jpg|images/foce.jpg|images/foce.jpg","product.asp|product.asp|product.asp","|||")
	  //a为swf宽度，b为swf高度,c为图片地址，d为相应的链接,e为显示的文字
					var swf_width=a;
					var swf_height=b;
					var files=c;
					var links=d;
					var texts=e;
					document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
				document.write('<param name="movie" value="images/bcastr3.swf"><param name="quality" value="high">');
				document.write('<param name="menu" value="false"><param name=wmode value="opaque"><param name=wmode value="transparen">');
				document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
				document.write('<embed src="images/bcastr3.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'&bcastr_config=0xffffff|2|0xffffff|85|0xffffff|0x58ac00|0x58ac00|2|2|2|_blank" menu="true" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); 
					}
					
//图片放大显示的jQuery插件演示页面
/*由于大图绑定在rev属性中，故一般而言，需使用a标签的href指向大图。仅支持png,gif,jpg,bmp四种格式的图片。用法是：目标.preview();
例如：<a href="xx.jpg">图片</a>
$("a").preview();就可以了
*/
(function($){
	$.fn.preview = function(){
		var xOffset = 10;
		var yOffset = 20;
		var w = $(window).width();
		$(this).each(function(){
			$(this).hover(function(e){
				if(/.png$|.gif$|.jpg$|.bmp$/.test($(this).attr("rev"))){
					$("body").append("<div id='preview'><div><img src='"+$(this).attr('rev')+"' /><p>"+$(this).attr('rel')+"</p></div></div>");
				}else{
					$("body").append("<div id='preview'><div><p>"+$(this).attr('rel')+"</p></div></div>");
				}
				$("#preview").css({
					position:"absolute",
					padding:"4px",
					border:"1px solid #f3f3f3",
					backgroundColor:"#eeeeee",
					top:(e.pageY - yOffset) + "px",
					zIndex:1000
				});
				$("#preview > div").css({
					padding:"5px",
					backgroundColor:"white",
					border:"1px solid #cccccc"
				});
				$("#preview > div > p").css({
					textAlign:"center",
					fontSize:"12px",
					padding:"8px 0 3px",
					margin:"0"
				});
				if(e.pageX < w/2){
					$("#preview").css({
						left: e.pageX + xOffset + "px",
						right: "auto"
					}).fadeIn("fast");
				}else{
					$("#preview").css("right",(w - e.pageX + yOffset) + "px").css("left", "auto").fadeIn("fast");	
				}
			},function(){
				$("#preview").remove();
			}).mousemove(function(e){
				$("#preview").css("top",(e.pageY - xOffset) + "px")
				if(e.pageX < w/2){
					$("#preview").css("left",(e.pageX + yOffset) + "px").css("right","auto");
				}else{
					$("#preview").css("right",(w - e.pageX + yOffset) + "px").css("left","auto");
				}
			});						  
		});
	};
})(jQuery);

//背景切换效果

var timer;
var slides = new Array();

//slides    FILENAME  ALT URL
slides[0] = ["images/bg1.jpg", "abc.", "http://www.abc.com"];
slides[1] = ["images/bg2.jpg", "CARE COORDINATORS. Life is precious and so is time. We're in the business of saving both.", "/CareCoordinator.aspx"];
slides[2] = ["images/bg1.jpg", "Visit our Health Library for more information.", "/home/healthLibrary.aspx"];
slides[3] = ["images/bg2.jpg", "SHARE YOUR STORY. Discover stories of hope, health, and healing at Florida Hospital.", "/AboutUs/Mission/OurStories.aspx"];

function getCurrentSlide() {

  var obj = document.getElementById("hdnSlideIndex");
  return parseInt(obj.value);

}

function saveCurrentSlide(slideIndex) {

  var obj = document.getElementById("hdnSlideIndex");
  obj.value = slideIndex;

}

function NextSlide() {

  ChangeSlide(getCurrentSlide() + 1);

}

function ChangeSlide(newSlideIndex) {

  clearTimeout(timer);

  if (newSlideIndex >= slides.length || newSlideIndex < 0) {
    newSlideIndex = 0;
  }

  jQuery("#mainBody").css("background", "none");
  jQuery("#main-body-bg").fadeOut("slow", function() {
    jQuery("#main-body-bg").css("background", "url(" + slides[newSlideIndex][0] + ") no-repeat top center");
    jQuery("#main-body-bg").fadeIn("slow");
  });

  SetSlideLink(newSlideIndex);

  saveCurrentSlide(newSlideIndex);

  timer = setTimeout("NextSlide()", 7000);

}

function SetSlideLink(slideIndex) {

  if (slideIndex >= slides.length || slideIndex < 0) {
    slideIndex = 0;
  }

  jQuery("#slideOverlay").attr("alt", slides[slideIndex][1]);
  jQuery("#image-map-learnmore").attr("href", slides[slideIndex][2]);

}

jQuery(document).ready(function() {
 // $('div#container').pngFix( );//ie6下png圆角
 //timer = setTimeout("NextSlide()", 7000);
});